# coding:utf-8
# 作者：理想国真恵玩
import pandas as pd

df_stock = pd.read_csv('data/stock.csv')
# print(df_stock.head())

# 提取股票涨跌幅
df_stock_p_change = df_stock['p_change']
# print(df_stock_p_change.head())

# 自动分组
df_stock_p_change_qcunt = pd.qcut(df_stock_p_change, 10)
# print(df_stock_p_change_qcunt)
# 统计每个组有多少个
# print(df_stock_p_change_qcunt.value_counts())

# 指定分组区间
bins = [-100, -7, -5, -3, 0, 3, 5, 7, 100]
df_stock_p_change_cunt = pd.cut(df_stock_p_change, bins)
# print(df_stock_p_change_cunt)
print(df_stock_p_change_cunt.value_counts())
